import http.server
import socketserver
from threading import Thread

from handler import RequestHandler

PORT = 8000
THREAD_NUM = 10 - 1

Handler = RequestHandler

if __name__ == '__main__':
    try:
        httpd = socketserver.TCPServer(("", PORT), Handler)
        for tid in range(THREAD_NUM):
            t = Thread(target=httpd.serve_forever)
            t.daemon = True
            t.start()
        httpd.serve_forever()
    except KeyboardInterrupt:
        httpd.shutdown()